<?php

/**
 * 
 */
class Admin_ReservaController extends App_Controller_Default {

    /**
     * 
     * @var Model_Mapper_Reserva
     */
    protected $_mapper;

    /**
     * 
     * @var Admin_Form_Reserva
     */
    protected $_form;

    /**
     * (non-PHPdoc)
     * @see Zend_Controller_Action::init()
     */
    public function init() {
        $this->view->noToolBar = true;

        $this->_mapper = new Model_Mapper_Reserva();
    }

    /**
     * 
     * @access 	protected
     * @param 	string $action
     * @return 	Admin_Form_Reserva
     */
    protected function _getForm($action) {
        if (is_null($this->_form)) {

            $this->_form = new Default_Form_Reserva();
            $this->_form->setAction($action);
        }

        return $this->_form;
    }

    /**
     * 
     * @access public
     * @return void
     */
    public function formPostHook() {
        $this->view->form->setAction($this->_helper->url('save'));
    }

    /**
     * 
     * @access public
     * @return void
     */
    public function editPostHook() {
        $this->view->form->setAction($this->_helper->url('save'));
    	
    	$id = $this->_getParam( 'id', 0 );
    	
    	$mapper = new Model_Mapper_Imagem();
    	$mapper->setData( array('lcl_id' => $id) );

    	$rows = $mapper->fetchImage();
    	
    	$image = array();
    	
    	foreach ( $rows as $row ) 
    	    $image[] = $row->img_id;
    	
    	$this->view->image = $image;
    	
    	
    	
    }

}